import django.utils.timezone as timezone


from django.db import models
from users.models import User
from amazondatas.models import SKU
from store.models import StoreManagement

from vne_erp.utils.base_model import BaseModel

# Create your models here.



# class Logistic(BaseModel):
#     """物流信息"""
#     shipping_method = models.CharField(max_length=50, verbose_name='买家指定邮寄方式')
#     logistics_method = models.CharField(max_length=50, verbose_name='物流方式')
#     tracking_number = models.CharField(max_length=20, verbose_name='跟踪号')
#     package_number = models.CharField(max_length=20, verbose_name='包裹号')
#
#

class GoodsRank(models.Model):
    Image = models.CharField(max_length=1024,blank=True, verbose_name="图片地址")
    title = models.CharField(max_length=512, verbose_name="标题")
    StoreName = models.CharField(max_length=64, default='', verbose_name="ASIN")
    SellerSKU = models.CharField(max_length=64, default='', verbose_name="ASIN")
    ASIN = models.CharField(max_length=16, verbose_name="ASIN")
    Time = models.DateTimeField(default=timezone.now, verbose_name='绩效日期')
    # order_numb = models.CharField(max_length=16,default='', verbose_name="订单量")
    sell_numb = models.CharField(max_length=16,default='', verbose_name="商品销量")
    goods_price = models.CharField(max_length=16, default='', verbose_name="单价")
    SalesChannel = models.CharField(max_length=32,default='', verbose_name='订单渠道')
    # unit_price = models.CharField(max_length=16, verbose_name="平均价格")
    class Meta:
        db_table = 'tb_goods_rank'
        verbose_name = "订单更新时间记录"
        verbose_name_plural = verbose_name




class CustomsDeclarationInfos(models.Model):
    """报关信息"""
    ChineseCustomsDeclaration = models.CharField(max_length=100, verbose_name="中文报关")
    EnglishCustomsDeclaration = models.CharField(max_length=100, verbose_name="英文报关")
    Weight = models.CharField(max_length=100, verbose_name="重量")
    Price = models.CharField(max_length=100, verbose_name="价格")
    CustomsCode = models.CharField(max_length=100, verbose_name="海关编码")
    IsElectric = models.BooleanField(default=False, verbose_name='是否带电') #1

    class Meta:
        db_table = 'tb_order_customsdeclarationinfos'
        verbose_name = "订单更新时间记录"
        verbose_name_plural = verbose_name


class UpdateTime(models.Model):
    """订单更新时间记录"""
    order_update_time = models.DateTimeField(default=timezone.now, verbose_name='订单更新的时间记录') #1

    class Meta:
        db_table = 'tb_order_update_time'
        verbose_name = "订单更新时间记录"
        verbose_name_plural = verbose_name


class Address(models.Model):
    """订单配送地址"""

    isAddressSharingConfidential = models.BooleanField(default=False, verbose_name='地址隐藏或共享')  #1 2
    Name = models.CharField(max_length=46, verbose_name='收件人姓名')  #1 2
    AddressLine1 = models.CharField(max_length=100, default='', verbose_name='街道地址')  #1 2
    AddressLine2 = models.CharField(max_length=100, default='', verbose_name='其他街道地址信息')   #1 2
    AddressLine3 = models.CharField(max_length=100, default='', verbose_name='其他街道地址信息')    # 1 2
    AddressType = models.CharField(max_length=100, default='', verbose_name='地址类型')    # 1 2
    City = models.CharField(max_length=50, verbose_name='城市')    #1 2
    Country = models.CharField(max_length=50, default='', verbose_name='区县')
    District = models.CharField(max_length=50, default='', verbose_name='区')
    StateOrRegion = models.CharField(max_length=50, verbose_name='省/自治区/直辖市或地区')  #1 2
    PostalCode = models.CharField(max_length=11, verbose_name='邮编')   #1 2
    CountryCode = models.CharField(max_length=11, verbose_name='国家/地区代码')  #1 2
    Phone = models.CharField(max_length=50, default='', verbose_name='电话')   #1

    class Meta:
        db_table = 'tb_address'
        verbose_name = "订单配送地址"
        verbose_name_plural = verbose_name


class Invoice(models.Model):

    """发票信息"""
    INVOICE_REQUIREMENT = (
        (1, 'Individual'),
        (2, 'Consolidated'),
        (3, 'MustNotSend'),
    )
    INVOICE_INFORMATION = (
        (1, 'NotApplicable'),
        (2, 'BuyerSelectedInvoiceCategory'),
        (3, 'ProductTitle'),
    )

    InvoiceRequirement = models.SmallIntegerField(choices=INVOICE_REQUIREMENT, default=3, verbose_name='发票要求')
    BuyerSelectedInvoiceCategory = models.CharField(max_length=100, verbose_name='发票类目信息')
    InvoiceTitle = models.CharField(max_length=100, verbose_name='发票抬头')
    InvoiceInformation = models.SmallIntegerField(choices=INVOICE_REQUIREMENT, default=3, verbose_name='发票信息')

    class Meta:
        db_table = 'tb_invoice'
        verbose_name = "发票信息"
        verbose_name_plural = verbose_name


class OrdersMoney(models.Model):
    CurrencyCode = models.CharField(max_length=10, verbose_name='三位数的货币代码')
    Amount = models.DecimalField(max_digits=8, decimal_places=2, verbose_name='货币金额')

    class Meta:
        db_table = 'tb_orders_money'
        verbose_name = "货币"
        verbose_name_plural = verbose_name


class OrdersItemMoney(models.Model):
    CurrencyCode = models.CharField(max_length=10, verbose_name='三位数的货币代码')
    Amount = models.CharField(max_length=20, verbose_name='货币金额')

    class Meta:
        db_table = 'tb_order_items_money'
        verbose_name = "货币"
        verbose_name_plural = verbose_name


class PaymentExecutionDetailItem(models.Model):
    PAYMENT_METHOD = (
        (1, 'COD'),    # 货到付款。仅适用于中国 (CN) 和日本 (JP)
        (2, 'GC'),     # 礼品卡 仅适用于中国 (CN) 和日本 (JP)
        (3, 'PointsAccount'),  # 亚马逊积分。仅适用于日本 (JP)
    )

    Payment = models.ForeignKey(OrdersMoney, on_delete=models.CASCADE, null=True, verbose_name='订单的总费用')
    PaymentMethod = models.SmallIntegerField(choices=PAYMENT_METHOD, default=1, verbose_name='发票信息')

    class Meta:
        db_table = 'tb_payment_execution_detail_item'
        verbose_name = "付款执行详细信息"
        verbose_name_plural = verbose_name


class PaymentMethodDDetails(models.Model):
    PaymentMethodDetail = models.CharField(max_length=100, verbose_name='详细支付方式')

    class Meta:
        db_table = 'tb_payment_method_details'
        verbose_name = "付款执行详细信息"
        verbose_name_plural = verbose_name


class ProductInfos(models.Model):
    NumberOfItems = models.CharField(max_length=10, default='', verbose_name='订单详情单数量')

    class Meta:
        db_table = 'tb_product_infos'
        verbose_name = "产品信息"
        verbose_name_plural = verbose_name


class TaxCollection(models.Model):
    Model = models.CharField(max_length=100, default='', verbose_name='模型')
    ResponsibleParty = models.CharField(max_length=100, default='', verbose_name='责任方')

    class Meta:
        db_table = 'tb_tax_collection'
        verbose_name = "税收征收"
        verbose_name_plural = verbose_name


# class ManyStatus(models.Model):
#     UnShipped = models.BooleanField(default=False, verbose_name='待审核')
#     UnDealed = models.BooleanField(default=False, verbose_name='待处理')
#     UnBilled = models.BooleanField(default=False, verbose_name='待打单')
#     Shipped = models.BooleanField(default=False, verbose_name='发货')
    # UnShipped = models.BooleanField(default=False, verbose_name='待处理')
    # UnShipped = models.BooleanField(default=False, verbose_name='待处理')
    # UnShipped = models.BooleanField(default=False, verbose_name='待处理')

class Orders(models.Model):
    """订单"""
    FULFILLMENT_CHANNEL = (
        (1, '亚马逊配送 (AFN)'),
        (2, '卖家自行配送 (MFN)'),
    )

    PAYMENT_METHOD = (
        (1, 'COD'),    # 货到付款。仅适用于中国 (CN) 和日本 (JP)
        (2, 'CVS'),     # 便利店。仅适用于日本 (JP)。
        (3, 'Other'),  # COD 和 CVS 之外的付款方式。
    )

    SHIPMENT_SERVICE_LEVEL_CATEGORY = (
        (1, 'Expedited'),
        (2, 'FreeEconomy'),
        (3, 'NextDay'),
        (4, 'SameDay'),
        (5, 'SecondDay'),
        (6, 'Scheduled'),
        (7, 'Standard'),
    )
    TFM_SHIPMENT_STATUS = (
        (1, 'PendingPickUp'),
        (2, 'LabelCanceled'),
        (3, 'PickedUp'),
        (4, 'AtDestinationFC'),
        (5, 'Delivered'),
        (6, 'RejectedByBuyer'),
        (7, 'Undeliverable'),
        (8, 'ReturnedToSeller'),
        (8, 'Other'),
    )
    ORDER_TYPE = (
        (1, 'StandardOrder'),   # 包含当前有库存商品的订单
        (2, 'Preorder'),    # 所含预售商品（发布日期晚于当前日期）的订单
    )

    SellerStore = models.ForeignKey(StoreManagement, on_delete=models.CASCADE, null=True, verbose_name='卖家店铺')
    # OrderItemId = models.ForeignKey(OrderItem, on_delete=models.CASCADE, null=True, verbose_name='订单详情id')
    LastUpdateDate = models.DateTimeField(default=timezone.now, verbose_name='订单的最后更新日期') #1
    PurchaseDate = models.DateTimeField(default=timezone.now, verbose_name='创建订单的日期') #1
    AmazonOrderId = models.CharField(max_length=100,unique=True, verbose_name='亚马逊订单ID') #1
    SellerOrderId = models.CharField(max_length=100, verbose_name='卖家自定义ID')
    OrderStatus = models.CharField(max_length=100, verbose_name='订单状态') #1
    IsReplacementOrder = models.BooleanField(default=False, verbose_name='是否为代售订单')  #1
    IsBusinessOrder = models.BooleanField(default=False, verbose_name='是否为商业订单') #1
    IsPremiumOrder = models.BooleanField(default=False, verbose_name='是否为附加订单') #1
    IsPrime = models.BooleanField(default=False, verbose_name='是否为首要订单') #1
    FulfillmentChannel = models.CharField(max_length=100, default='', verbose_name='发票信息') #1
    SalesChannel = models.CharField(max_length=100, verbose_name='订单第一件商品销售渠道') #1
    OrderChannel = models.CharField(max_length=100, verbose_name='订单第一件商品订单渠道')
    ShippingAddress = models.OneToOneField(Address, on_delete=models.CASCADE, null=True, verbose_name='订单配送地址') #1
    ShipServiceLevel = models.CharField(max_length=100, verbose_name='货件服务水平') #1
    OrderTotal = models.OneToOneField(OrdersMoney, on_delete=models.CASCADE, null=True, verbose_name='订单的总费用') #1
    NumberOfItemsShipped = models.IntegerField(default=0, verbose_name='已配送商品数量') #1
    NumberOfItemsUnshipped = models.IntegerField(default=0, verbose_name='未配送商品数量') #1
    # PaymentMethodDetails = models.ForeignKey(PaymentMethodDDetails, on_delete=models.CASCADE, null=True, verbose_name='货到付款') #1
    """	货到付款 (COD) 订单的次级付款方式的相关信息。COD 订单是带有PaymentMethod = COD 的订单。包含一个或多个PaymentExecutionDetailItem响应元素。
注： 对于使用某一次级付款方式付款的 COD 订单，将返回一个 PaymentExecutionDetailItem响应元素，其中 PaymentExecutionDetailItem/PaymentMethod = COD。对于使用多种次级付款方式付款的 COD 订单，将返回两个或多个 PaymentExecutionDetailItem响应元素。
可选。仅对 COD 订单返回。仅适用于中国 (CN) 和日本 (JP)。"""
    PaymentMethod = models.CharField(max_length=100, default='', verbose_name='订单的主要付款方式') #1
    MarketplaceId = models.CharField(max_length=100, verbose_name='订单生成所在商城的匿名编码') #1
    BuyerEmail = models.CharField(max_length=100, verbose_name='买家的匿名电子邮件地址') #1
    BuyerName = models.CharField(max_length=100, verbose_name='买家姓名') #1
    ShipmentServiceLevelCategory = models.CharField(max_length=100, default='', verbose_name='订单的配送服务级别分类')  #1
    ShippedByAmazonTFM = models.BooleanField(default=False, verbose_name='配送服务是否由亚马逊配送')  #1
    TFMShipmentStatus = models.CharField(max_length=100, default='', verbose_name='亚马逊TFM状态')  # 只有当ShippedByAmazonTFM=True时才有返回
    CbaDisplayableShippingLabel = models.CharField(max_length=100, verbose_name='卖家自定义的配送方式')
    OrderType = models.CharField(max_length=100, default='', verbose_name='订单类型')  #1

    EarliestShipDate = models.DateTimeField(default=timezone.now, verbose_name='您承诺的订单发货时间范围的第一天')  #1
    LatestShipDate = models.DateTimeField(default=timezone.now, verbose_name='您承诺的订单发货时间范围的最后一天')  #1
    EarliestDeliveryDate = models.DateTimeField(default=timezone.now, verbose_name='您承诺的订单送达时间范围的第一天')  #1
    LatestDeliveryDate = models.DateTimeField(default=timezone.now, verbose_name='您承诺的订单送达时间范围的最后一天')  #1

    TrackingNumber = models.CharField(max_length=100, default="", blank=True, verbose_name='跟踪号')
    WayBillNumber = models.CharField(max_length=100, default="", verbose_name='运单号')

    MerchantOrderID = models.CharField(max_length=100, default='', verbose_name='卖家所定义的订单编码') #1
    MerchantFulfillmentID = models.CharField(max_length=100, default='', verbose_name='卖方提供的货件唯一标识符') #1

    # Info = models.CharField(max_length=100, default='', verbose_name='备注信息')  # 1
    # Status = models.OneToOneField(ManyStatus, on_delete=models.CASCADE,related_name='status', null=True, verbose_name='订单状态') #1
    Examine = models.BooleanField(default=False, verbose_name='审核')
    Deal = models.BooleanField(default=False, verbose_name='处理')
    ApplicationOrderNumber = models.BooleanField(default=False, verbose_name='申请单号')
    FaceSheet = models.BooleanField(default=False, verbose_name='打印面单')
    Shipped = models.BooleanField(default=False, verbose_name='发货')
    IsSubmitTrackingNumber = models.BooleanField(default=False, verbose_name='提交单号')
    # IsInventedDeliver = models.BooleanField(default=False, verbose_name='虚拟发货')


    TQName = models.CharField(max_length=64, default="", verbose_name='本站订单唯一编号')




    class Meta:
        db_table = 'tb_orders'
        verbose_name = "订单详情"
        verbose_name_plural = verbose_name

class Infos(BaseModel):
    Order = models.ForeignKey(Orders, on_delete=models.CASCADE, null=True, verbose_name='订单ID')
    Info = models.CharField(max_length=100, default='', verbose_name='备注信息')
    username = models.CharField(max_length=30, default='', verbose_name='备注人')
    class Meta:
        db_table = 'tb_infos'
        verbose_name = "备注信息"
        verbose_name_plural = verbose_name

class OrderItem(models.Model):
    """OrderItem 信息"""

    CONDITION_ID = (
        (1, 'New'),
        (2, 'Used'),
        (3, 'Collectible'),
        (4, 'Refurbished'),
        (5, 'Preorder'),
        (6, 'Club'),
    )
    CONDITION_SUBTYPE_ID = (
        (1, 'New'),
        (2, 'Used'),
        (3, 'Very Good'),
        (4, 'Good'),
        (5, 'Acceptable'),
        (6, 'Poor'),
        (7, 'Club'),
        (8, 'OEM'),
        (9, 'Warranty'),
        (10, 'Refurbished Warranty'),
        (11, 'Refurbished'),
        (12, 'Open Box'),
        (13, 'Any'),
        (14, 'Other'),
    )

    """ 
    ItemPrice,ShippingPrice,GiftWrapPrice,ItemTax,ShippingTax,GiftWrapTax,ShippingDiscountTax,ShippingDiscount,PromotionDiscountTax
    PromotionDiscount,CODFee,CODFeeDiscount,
    """
    CustomsDeclarationInfo = models.ForeignKey(CustomsDeclarationInfos, on_delete=models.CASCADE, null=True, verbose_name='报关信息')
    Order = models.ForeignKey(Orders, on_delete=models.CASCADE, null=True, verbose_name='订单ID')
    # AmazonOrderId = models.CharField(max_length=100, default='', verbose_name='亚马逊订单ID')
    ASIN = models.CharField(max_length=100, default='', verbose_name='ASIN')
    SellerSKU = models.CharField(max_length=100, default='', verbose_name='商品的卖家 SKU')
    OrderItemId = models.CharField(max_length=100, default='', verbose_name='亚马逊定义的订单商品识别号')
    Title = models.CharField(max_length=300, default='', verbose_name='商品名称')
    QuantityOrdered = models.CharField(max_length=10, default='', verbose_name='下面两个子元素的父元素')  #
    QuantityShipped = models.CharField(max_length=10, default='', verbose_name='已配送的商品数量')
    IsGift = models.BooleanField(default=False, verbose_name='是否为礼品')
    IsTransparency = models.BooleanField(default=False, verbose_name='是否可视化')
    ProductInfo = models.OneToOneField(ProductInfos, on_delete=models.CASCADE, null=True, verbose_name='产品信息')
    TaxCollection = models.OneToOneField(TaxCollection, on_delete=models.CASCADE, null=True, verbose_name='税收征收')  #
    ItemPrice = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="ItemPrice", null=True, verbose_name='订单商品的售价')
    ShippingPrice = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="ShippingPrice", null=True, verbose_name='运费')
    GiftWrapPrice = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="GiftWrapPrice", null=True, verbose_name='商品的礼品包装金额')
    ItemTax = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="ItemTax", null=True, verbose_name='商品价格的税费')
    ShippingTax = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="ShippingTax", null=True, verbose_name='运费的税费')
    GiftWrapTax = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="GiftWrapTax", null=True, verbose_name='礼品包装金额的税费')
    ShippingDiscountTax = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="ShippingDiscountTax", null=True, verbose_name='运费的折扣税')
    ShippingDiscount = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="ShippingDiscount", null=True, verbose_name='运费的折扣')
    PromotionDiscountTax = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="PromotionDiscountTax", null=True, verbose_name='报价中的全部促销折扣总计')
    PromotionDiscount = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="PromotionDiscount", null=True, verbose_name='促销折扣')
    CODFee = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="CODFee", null=True, verbose_name='COD 服务费用')
    CODFeeDiscount = models.OneToOneField(OrdersItemMoney, on_delete=models.CASCADE, related_name="CODFeeDiscount", null=True, verbose_name='货到付款费用的折扣')
    GiftMessageText = models.CharField(max_length=100, default='', verbose_name='买家提供的礼品消息')
    GiftWrapLevel = models.CharField(max_length=100, default='', verbose_name='买家指定的礼品包装等级')
    InvoiceData = models.OneToOneField(Invoice, on_delete=models.CASCADE, null=True, verbose_name='发票信息')
    ConditionNote = models.CharField(max_length=100, default='', verbose_name='卖家描述的商品状况')
    ConditionId = models.CharField(max_length=100, default='', verbose_name='商品的状况')
    ConditionSubtypeId = models.CharField(max_length=100, default='', verbose_name='商品的子状况')
    ScheduledDeliveryStartDate = models.DateTimeField(default=timezone.now, verbose_name='订单预约送货上门的开始日期（目的地时区）')
    ScheduledDeliveryEndDate = models.DateTimeField(default=timezone.now, verbose_name='订单预约送货上门的终止日期（目的地时区）')

    GoodsImage = models.CharField(max_length=100, default='', verbose_name='商品图片')

    MerchantOrderItemID = models.CharField(max_length=100, default='', verbose_name='卖方为订单中的商品提供的可选ID') #1
    MerchantFulfillmentItemID = models.CharField(max_length=100, default='', verbose_name='卖方提供的商品的唯一标识符装运') #1
    sku = models.ForeignKey(SKU, on_delete=models.CASCADE, null=True, verbose_name='商品信息')




    class Meta:
        db_table = 'tb_order_items'
        verbose_name = "订单项信息"
        verbose_name_plural = verbose_name

class PromotionIds(models.Model):
    """OrderItem的promotion_id列表"""
    OrderItemId = models.ForeignKey(OrderItem, on_delete=models.CASCADE, verbose_name='报价中的全部促销折扣总计')

    class Meta:
        db_table = 'tb_promotions'
        verbose_name = "促销单列表"
        verbose_name_plural = verbose_name


class OrderCount(BaseModel):
    """订单量"""
    to_examine = models.IntegerField(default=0, verbose_name='待审核')
    to_handle = models.IntegerField(default=0, verbose_name='待处理')
    private_warehouse = models.IntegerField(default=0, verbose_name='自营仓库')
    the_third_warehouse = models.IntegerField(default=0, verbose_name='第三方仓库')
    have_goods = models.IntegerField(default=0, verbose_name='有货')
    no_goods = models.IntegerField(default=0, verbose_name='缺货')
    deliver_goods_failed = models.IntegerField(default=0, verbose_name='发货成功')
    deliver_goods_success = models.IntegerField(default=0, verbose_name='发货失败')
    refused = models.IntegerField(default=0, verbose_name='已退款')
    shelve = models.IntegerField(default=0, verbose_name='已搁置')

    class Meta:
        db_table = 'tb_order_counts'
        verbose_name = '订单量'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s: %s' % (self.id, self.deliver_goods_failed)


# Create your models here.


class OrderInfo(BaseModel):
    """
    订单信息
    """

    PAY_METHOD_CHOICES = (
        (1, "已支付"),
        (2, "未支付"),
    )

    ORDER_STATUS_CHOICES = (
        (1, "待审核"),
        (2, "待处理"),
        (3, "自营仓库"),
        (4, "第三方仓库"),
        (5, "有货"),
        (7, "缺货"),
        (8, "发货成功"),
        (9, "发货失败"),
        (10, "已退款"),
        (11, "已搁置"),
    )

    order_id = models.CharField(max_length=64, verbose_name="订单号")
    goods_info = models.CharField(max_length=64, verbose_name='商品信息')
    total_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="商品总金额")
    buyer = models.CharField(max_length=46, verbose_name="下单用户")

    get_order_time = models.CharField(max_length=30, verbose_name='下单时间')
    submit_order_time = models.CharField(max_length=30, verbose_name='提交时间')
    deliver_time = models.CharField(max_length=30, verbose_name='发货时间')

    logistics_method = models.CharField(max_length=50, verbose_name='物流方式')
    tracking_number = models.CharField(max_length=20, verbose_name='跟踪号')
    freight = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="运费")
    status = models.SmallIntegerField(choices=ORDER_STATUS_CHOICES, default=1, verbose_name="订单状态")


    class Meta:
        db_table = "tb_order_info"
        verbose_name = '订单基本信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s: %s' % (self.id, self.order_id)


class OrderGoods(BaseModel):
    """
    订单商品
    """
    SCORE_CHOICES = (
        (0, '0星'),
        (1, '1星'),
        (2, '2星'),
        (3, '3星'),
        (4, '4星'),
        (5, '5星'),
    )
    ORDER_SOURCE = (
        (1, 'AMAZON'),
        (2, 'JOOM'),
        (3, '1688'),
        (4, 'DJY'),
        (5, 'OTHERS')

    )
    order_id = models.ForeignKey(OrderInfo, on_delete=models.PROTECT, verbose_name="订单")
    seller = models.ForeignKey(User, on_delete=models.PROTECT, verbose_name='卖家')
    order_source = models.SmallIntegerField(choices=ORDER_SOURCE, default=1, verbose_name='站点')

    # 收货地址
    addressee = models.CharField(max_length=46, verbose_name='收件人')
    address_1 = models.CharField(max_length=100, verbose_name='收货地址1')
    address_2 = models.CharField(max_length=100, verbose_name='收货地址2')
    city = models.CharField(max_length=50, verbose_name='城市')
    province = models.CharField(max_length=50, verbose_name='省市')
    country = models.CharField(max_length=50, verbose_name='国家')
    postal_code = models.CharField(max_length=11, verbose_name='邮编')
    phone = models.CharField(max_length=11, verbose_name='电话')
    mobile = models.CharField(max_length=11, verbose_name='手机')

    pay_status = models.BooleanField(default=0, verbose_name='付款状态')
    sku = models.ForeignKey(SKU, on_delete=models.PROTECT, verbose_name="订单商品")
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="单价")
    count = models.IntegerField(default=1, verbose_name="数量")

    # 物流方式
    shipping_method = models.CharField(max_length=50, verbose_name='买家指定邮寄方式')
    logistics_method = models.CharField(max_length=50, verbose_name='物流方式')
    tracking_number = models.CharField(max_length=20, verbose_name='跟踪号')
    package_number = models.CharField(max_length=20, verbose_name='包裹号')

    remark = models.CharField(max_length=100, verbose_name='备注')
    leave_message = models.CharField(max_length=100, verbose_name='留言')
    comment = models.TextField(default="", verbose_name="评价信息")
    score = models.SmallIntegerField(choices=SCORE_CHOICES, default=5, verbose_name='满意度评分')

    class Meta:
        db_table = "tb_order_goods"
        verbose_name = '订单商品'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s: %s' % (self.id, self.addressee)


# class PaymentExecutionDetailItem(models.Model):
#     PAYMENT_METHOD = (
#         (1, 'COD'),    # 货到付款。仅适用于中国 (CN) 和日本 (JP)
#         (2, 'GC'),     # 礼品卡 仅适用于中国 (CN) 和日本 (JP)
#         (3, 'PointsAccount'),  # 亚马逊积分。仅适用于日本 (JP)
#     )
#     PaymentExecutionDetail = models.ForeignKey(Orders, on_delete=models.CASCADE, null=True,
#                                                verbose_name='货到付款')  # 1
#     Payment = models.OneToOneField(Money, on_delete=models.CASCADE, null=True, verbose_name='订单的总费用')
#     PaymentMethod = models.SmallIntegerField(choices=PAYMENT_METHOD, default=1, verbose_name='发票信息')
#
#     class Meta:
#         db_table = 'tb_payment_execution_detail_item'
#         verbose_name = "付款执行详细信息"
#         verbose_name_plural = verbose_name
